Isolated storage using System.IO.IsolatedStorage; ..... IsolatedStorageSettings appSettings = IsolatedStorageSettings.ApplicationSettings; appSettings["Agent"] = "Longtarin"; appSettings["ID"] = 15; // ou : appSettings.Add("ID", 15); appSettings.Save(); IsolatedStorageSettings appSettings = IsolatedStorageSettings.ApplicationSettings; string agent = appSettings["Agent"].ToString(); int id = (int)appSettings["ID"]; Imports System.IO.IsolatedStorage ..... Dim appSettings As IsolatedStorageSettings _ = IsolatedStorageSettings.ApplicationSettings appSettings("Agent") = "Longtarin" appSettings("ID") = 15 appSettings.Save() ..... Dim n As Integer = appSettings("Année") using System.IO.IsolatedStorage; ..... IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication(); string[] ts = isf.GetFileNames(); foreach (string s in ts) ..... using System.Text // pour UTF8Encoding ..... IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication(); IsolatedStorageFileStream fs = isf.CreateFile("Fich.dat"); string s = "Fichier créé le " + DateTime.Now.ToShortDateString() + " à " + DateTime.Now.ToLongTimeString(); // conversion de string en byte[] UTF8Encoding enc = new UTF8Encoding(); fs.Write(enc.GetBytes(s), 0, s.Length); fs.Close(); IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication(); IsolatedStorageFileStream fs = isf.OpenFile("Fich.dat", System.IO.FileMode.Open); int N = (int)fs.Length; // taille du fichier byte[] tb = new byte[N]; // tableau de réception fs.Read(tb, 0, N); // convertir tb en une chaîne de caractères UTF8Encoding enc = new UTF8Encoding(); string s = enc.GetString(tb, 0, tb.Length); Private Sub bEcrire_Click(ByVal sender As System.Object, _ ByVal e As System.Windows.RoutedEventArgs) Dim isf As IsolatedStorageFile =_ IsolatedStorageFile.GetUserStoreForApplication() Dim fs As IsolatedStorageFileStream = isf.CreateFile("Fichvb.dat") Dim s As String = "Fichier créé le " & DateTime.Now.ToShortDateString() & " à " _& DateTime.Now.ToLongTimeString() Dim enc As New UTF8Encoding fs.Write(enc.GetBytes(s), 0, s.Length) fs.Close() End Sub Private Sub bLire_Click(ByVal sender As System.Object, _ ByVal e As System.Windows.RoutedEventArgs) Dim isf As IsolatedStorageFile = IsolatedStorageFile.GetUserStoreForApplication() Dim fs As IsolatedStorageFileStream = isf.OpenFile("Fichvb.dat",_ System.IO.FileMode.Open) Dim N As Integer = CInt(Fix(fs.Length)) ' taille du fichier Dim tb(N - 1) As Byte ' tableau de réception fs.Read(tb, 0, N) ' convertir tb en une chaîne de caractères Dim enc As New UTF8Encoding() Dim s As String = enc.GetString(tb, 0, tb.Length) End Sub using System.IO.IsolatedStorage; using System.IO; IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication(); IsolatedStorageFileStream isfs = new IsolatedStorageFileStream("App.dat", FileMode.Create, isf); StreamWriter sw = new StreamWriter(isfs); sw.WriteLine("Première ligne"); sw.WriteLine("Deuxième ligne"); sw.Close(); isfs.Close(); IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication(); IsolatedStorageFileStream isfs = isf.OpenFile("App.dat", FileMode.Open); StreamReader sr = new StreamReader(isfs); string s1 = sr.ReadLine(); string s2 = sr.ReadLine(); sr.Close(); isfs.Close(); Lire des fichiers distants using System.Net; using System.IO; ..... WebClient client = new WebClient(); client.OpenReadCompleted += new OpenReadCompletedEventHandler(client_OpenReadCompleted); client.OpenReadAsync(new Uri("Fich.txt", UriKind.Relative)); ..... void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e) { StreamReader sr = new StreamReader(e.Result); string s = sr.ReadLine(); while (s != null) { ..... // contenu de la ligne dans s s = sr.ReadLine(); } } Lire des fichiers locaux using System.IO; using System.Text; ..... OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Fichiers de texte|*.txt"; if (ofd.ShowDialog() == DialogResult.OK) { Stream str = ofd.SelectedFile.OpenRead(); int N = (int)str.Length; // taille du fichier de texte byte[] tb = new byte[N]; str.Read(tb, 0, N); // lire tout le contenu du fichier // amener le contenu du fichier local dans une variable de type string s = UTF8Encoding.UTF8.GetString(tb, 0, N); str.Close(); } StreamReader sr = ofd.SelectedFile.OpenText(); s = sr.ReadToEnd(); sr.Close(); Les fichiers en ressources using System.Windows.Resources; using System.IO; ..... StreamResourceInfo sri = Application.GetResourceStream( new Uri("SLProg;component/SLRes.txt", UriKind.Relative)); StreamReader sr = new StreamReader(sri.Stream); string s1 = sr.ReadLine(); string s2 = sr.ReadLine();